<?php
$page_table = DB::$tables['page'];
$access_type_table = DB::$tables['access_type'];

	$allpages = exec_sql2array( 'SELECT '.
		'page_path '.
		',page_alias '.
		',page_access '.
		',page_template '.
		',page_title '.
		//',page_meta_desc '.
		//',page_meta_key '.
		//',page_add_head '.
		//',page_html '.
		',page_load_from_db '.
		',page_note '.
	' FROM '.$page_table ); myPrint($allpages,'$allpages'); 

	$cols=exec_sql2array( 'SELECT COLUMN_NAME, COLUMN_COMMENT '.
		'FROM information_schema.columns '.
		'WHERE table_name = \''.$page_table.'\' AND table_schema = \''.DB_NAME.'\'');
		
	foreach($cols as $colArr) $colTitle[$colArr['COLUMN_NAME']] = $colArr['COLUMN_COMMENT']; myPrint($colTitle,'$colTitle'); 
	
	if(count($allpages)>0){
		$th='';
		foreach( $allpages[0] as $name=>$value) {
			$title = !empty($colTitle[$name]) ? $colTitle[$name] : $name;
			switch($name){
				case 'page_load_from_db':
					$title='<span title="'.$title .'">'.'From DB'.'</span>';
				break;
				case 'page_note':
					$title='<span title="'.$title .'">'.'Note'.'</span>';
				break;				
			}
			$th.='<th>'.$title.'</th>'."\n";
		}
		
		$trs=''; $num=0;
		foreach($allpages as $pageArr){
			$tr=''; $num++;
			foreach($pageArr as $name=>$value) {
				
				switch($name){
					case 'page_path':
						$onclickWO = 'onclick="window.open( this.href, \'admin_popur_edit\', \'width=600,height=800\'); return false;"';
						$value = '<a '.$onclickWO .' title="'.Lang::get('TO_ADJUST').'..." class="setting_but" href="/admin/modules/content/PageProperty.php?page_path='.$value.'"></a>'.'<a title="'.Lang::get('TO_SHOW').'..." href="'.$value.'">'.$value.'</a>';
					break;
					case 'page_access':
						$_value = '';
						$access_types= exec_sql2array('SELECT * FROM  `'.$access_type_table.'`');
						foreach($access_types as $arr) $types[$arr['access_type_id']] = $arr['access_type_name'];
						$unser = unserialize( $value );
						if(is_array($unser)) foreach( $unser as $id ) $_value.=$types[$id].'<br/>';
						$value =$_value;
					break;
					case 'page_load_from_db':
						$value = empty($value)?Lang::get('NO'):Lang::get('YES');
					break;
					case 'page_template':
						$value = empty($value)?'default':$value;
					break;
				}
				
				$tr.='<td>'.$value.'</td>'."\n";
			}
			$trs.='<tr class="'.( $num%2?'':'odd' ).'" >'.$tr.'</tr>'."\n";
		}
		
		echo $table = '<table class="admin_table"><thead>'.$th.'</thead><tbody>'.$trs.'</tbody></table>';		
	}

	
?>